<template>
	<view class="upload-box">
		<view class="title">{{tip}}</view>
		<view class="upload-image">
			<view class="upload" v-if="!isJustShow" @click="chooseImage">
				<image :src="$getImageSrc('camera.png')" mode=""></image>
			</view>
			<image class="showImage" :src='imageSrc' mode="heightFix"></image>
		</view>
	</view>
</template>

<script>
	import {upload} from '@/untils/api.js'
	export default {
		name:"upload-image",
		props:{
			isJustShow:{
				type:Boolean,
				default:false
			},
			tip:{
				type:String,
				default:'正面'
			},
			imageSrc:{
				type:String,
				default:''
			}
		},
		data() {
			return {
		        // currImageSrc:this.imageSrc
			};
		},
		methods:{
			chooseImage(){
				this.$uploadFile().then((res) => {
					this.$emit('update:imageSrc', res)
					// this.currImageSrc = res
				})
			}
		}
	}
</script>

<style lang="scss">
.upload-box{
	width: 90%;
	margin: 0 auto 20rpx;
	overflow: hidden;
	border-bottom: 1px solid #f8f8f8;
	.title{
		line-height: 60rpx;
	}
	.upload-image{
		display: flex;
		justify-content: flex-start;
		align-items: center;
		margin-bottom: 20rpx;
		.upload{
			width: 200rpx;
			height: 200rpx;
			background-color: #eee;
			display: flex;
			justify-content: center;
			align-items: center;
			margin-right: 40rpx;
			image{
				width:64rpx;
				height: 64rpx;
			}
		}
	}
	.showImage{
		height: 200rpx;
		max-width:calc(100% - 240rpx)
	}
}
</style>